package com.parsechina.hpush.broker.internal;

import io.netty.channel.Channel;

import java.util.Objects;

/**
 * @author linfeng
 * @since 2016/11/22
 */
public class ConnectionDescriptor {
    private final String clientId;
    private final Channel channel;
    private final boolean cleanSession;

    public ConnectionDescriptor(String clientId, Channel session, boolean cleanSession) {
        this.clientId = clientId;
        this.channel = session;
        this.cleanSession = cleanSession;
    }

    public String getClientId() {
        return clientId;
    }

    public Channel getChannel() {
        return channel;
    }

    public boolean isCleanSession() {
        return cleanSession;
    }

    @Override
    public String toString() {
        return "ConnectionDescriptor{" + "clientId=" + clientId + ", cleanSession=" + cleanSession + '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ConnectionDescriptor that = (ConnectionDescriptor) o;
        return cleanSession == that.cleanSession &&
                Objects.equals(clientId, that.clientId) &&
                Objects.equals(channel, that.channel);
    }

    @Override
    public int hashCode() {
        return Objects.hash(clientId, channel, cleanSession);
    }
}
